const {data}=require('./src/mock')
const bodyparser =require('body-parser')

module.exports={
    devServer:{
        before:app=>{
            app.use(bodyparser.json())
            app.post('/api/list',(req,res)=>{
                res.send({
                    code:200,
                    data
                })
            })
            app.post('/api/edit',(req,res)=>{
                let {id}=req.body
                let newData=data.find(item=>item.id===id)
                res.send({
                    code:200,
                    data:newData
                })
            })
            app.post('/api/edititem',(req,res)=>{
                let obj=req.body
                let F=data.find(item=>item.id===obj.id)
                F.account=obj.account,
                F.nickname=obj.nickname,
                res.send({
                    code:200,
                    data
                })
            })
        }
    }
}